﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LambdaProj
{
    public static class LinqHelper
    {
        public static int Ext(this IEnumerable<int> lint)
        {
            return lint.Count();
        }

        public static string GetType4444(this object obj)
        {
            return obj.GetType().ToString();
        }

        public static IEnumerable<int> GetMyEL()
        {
            yield return 1;
            yield return 1;
            yield return 1;
            yield return 1;
            yield return 1;
            yield return 1;
        }

        public static void IntoDemo()
        {
            string[] words = { "apples","blueberries","oranges","bananas","apricots"};
            var wordGroup1 = from w in words
                             group w by w[0] into fruitGroup
                             where fruitGroup.Count() >= 2
                             select new {FirstLetter=fruitGroup.Key,Words = fruitGroup.Count() };

            foreach(var item in wordGroup1)
            {
                Console.WriteLine("{0} has {1} elements",item.FirstLetter,item.Words);

            }
        }

    }
}
